<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake工程描述编写之选择性编译</title>
    <meta name="description" content="xmake 提供了一些内置的条件判断api，用于在选择性编译时，获取到一些工程状态的相关信息，来调整编译逻辑。。例如：is_os, is_plat, is_arch, is_kind, is_mode, is_optionis_mode我们先拿最常用的is_mode来讲讲如何使用，这个api主要用来判断当前的编译...">

    
    <meta name="keywords" content="xmake,编译,工程描述,xmake.lua,条件判断,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2016/07/23/condition-and-select-compile/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake工程描述编写之选择性编译</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2016-07-23
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#%E7%BC%96%E8%AF%91" title="Tag: 编译" rel="tag">编译</a-->
        <a href="/cn/tag/#编译" title="Tag: 编译" rel="tag">编译</a>&nbsp;
    
        <!--a href="/tag/#%E5%B7%A5%E7%A8%8B%E6%8F%8F%E8%BF%B0" title="Tag: 工程描述" rel="tag">工程描述</a-->
        <a href="/cn/tag/#工程描述" title="Tag: 工程描述" rel="tag">工程描述</a>&nbsp;
    
        <!--a href="/tag/#xmake.lua" title="Tag: xmake.lua" rel="tag">xmake.lua</a-->
        <a href="/cn/tag/#xmake.lua" title="Tag: xmake.lua" rel="tag">xmake.lua</a>&nbsp;
    
        <!--a href="/tag/#%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD" title="Tag: 条件判断" rel="tag">条件判断</a-->
        <a href="/cn/tag/#条件判断" title="Tag: 条件判断" rel="tag">条件判断</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>xmake 提供了一些内置的条件判断api，用于在选择性编译时，获取到一些工程状态的相关信息，来调整编译逻辑。。</p>

<p>例如：<code class="highlighter-rouge">is_os</code>, <code class="highlighter-rouge">is_plat</code>, <code class="highlighter-rouge">is_arch</code>, <code class="highlighter-rouge">is_kind</code>, <code class="highlighter-rouge">is_mode</code>, <code class="highlighter-rouge">is_option</code></p>

<h3 id="is_mode"><code class="highlighter-rouge">is_mode</code></h3>

<p>我们先拿最常用的<code class="highlighter-rouge">is_mode</code>来讲讲如何使用，这个api主要用来判断当前的编译模式，例如平常编译配置的时候，会执行：</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -m debug
<span class="gp">$ </span>xmake
</code></pre>
</div>

<p>来编译<code class="highlighter-rouge">debug</code>版本，那么模式就是<code class="highlighter-rouge">debug</code>，那么<code class="highlighter-rouge">release</code>版本，也就是<code class="highlighter-rouge">release</code>了</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -m release
<span class="gp">$ </span>xmake
</code></pre>
</div>

<p>但是如果仅仅只是这么配置，xmake还是不知道如果为debug进行编译，如何编译release版本，因为这些模式的值不是内置的</p>

<p>我们可以随便设置，例如：profile, checking等等，用来编译性能模式，检测模式，这些就看咱们项目实际的需求了。。</p>

<p>一般情况下只需要<code class="highlighter-rouge">debug</code>和<code class="highlighter-rouge">release</code>就行了，那如何区分呢，这就需要在<code class="highlighter-rouge">xmake.lua</code>进行配置了，一般可参考如下配置：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 如果当前编译模式是debug</span>
<span class="k">if</span> <span class="n">is_mode</span><span class="p">(</span><span class="s2">"debug"</span><span class="p">)</span> <span class="k">then</span>

    <span class="c1">-- 添加DEBUG编译宏</span>
    <span class="n">add_defines</span><span class="p">(</span><span class="s2">"DEBUG"</span><span class="p">)</span>

    <span class="c1">-- 启用调试符号</span>
    <span class="n">set_symbols</span><span class="p">(</span><span class="s2">"debug"</span><span class="p">)</span>

    <span class="c1">-- 禁用优化</span>
    <span class="n">set_optimize</span><span class="p">(</span><span class="s2">"none"</span><span class="p">)</span>

<span class="c1">-- 如果是release模式</span>
<span class="k">elseif</span> <span class="n">is_mode</span><span class="p">(</span><span class="s2">"release"</span><span class="p">)</span> <span class="k">then</span>

    <span class="c1">-- 隐藏符号</span>
    <span class="n">set_symbols</span><span class="p">(</span><span class="s2">"hidden"</span><span class="p">)</span>

    <span class="c1">-- strip所有符号</span>
    <span class="n">set_strip</span><span class="p">(</span><span class="s2">"all"</span><span class="p">)</span>

    <span class="c1">-- 开启优化为：最快速度模式</span>
    <span class="n">set_optimize</span><span class="p">(</span><span class="s2">"fastest"</span><span class="p">)</span>

    <span class="c1">-- 忽略帧指针</span>
    <span class="n">add_cxflags</span><span class="p">(</span><span class="s2">"-fomit-frame-pointer"</span><span class="p">)</span>
    <span class="n">add_mxflags</span><span class="p">(</span><span class="s2">"-fomit-frame-pointer"</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</div>

<p>通过判断是否在编译debug版本，来启用和禁用调试符号信息，并且判断是否禁用和启用优化。</p>

<p>当然，如果我们的项目还设置了其他模式，例如性能分析模式：profile，那么还可以通过这个来判断是否需要添加一些分析分析上的编译选项。</p>

<h3 id="is_plat"><code class="highlighter-rouge">is_plat</code></h3>

<p>接下来我们讲讲这个编译平台的判断，这个也非常实用哦，虽然我们的工具是为了跨平台开发，通常的配置肯定都是通用的</p>

<p>但是毕竟项目成千上万，需求各不相同，总归会有些项目需要针对不同的平台做些编译上的特殊处理</p>

<p>这个时候，我们就需要这个api了，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 如果当前平台是android</span>
<span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"android"</span><span class="p">)</span> <span class="k">then</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/xxx/*.c"</span><span class="p">)</span>
<span class="k">end</span>

<span class="c1">--如果当前平台是macosx或者iphoneos</span>
<span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"macosx"</span><span class="p">,</span> <span class="s2">"iphoneos"</span><span class="p">)</span> <span class="k">then</span>
    <span class="n">add_mxflags</span><span class="p">(</span><span class="s2">"-framework Foundation"</span><span class="p">)</span>
    <span class="n">add_ldflags</span><span class="p">(</span><span class="s2">"-framework Foundation"</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</div>

<p>这里针对android平台，增加了一些特殊代码的编译，针对macosx和iphoneos平台，增加了Foundation框架的链接。</p>

<p>这里还有个比较实用的小技巧，<code class="highlighter-rouge">is_xxx</code>系列接口，都是可以同时传递多个参数的，逻辑上是or的关系</p>

<p>我们可以像上面那么写法：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"macosx"</span><span class="p">,</span> <span class="s2">"iphoneos"</span><span class="p">,</span> <span class="s2">"android"</span><span class="p">,</span> <span class="s2">"linux"</span><span class="p">)</span> <span class="k">then</span>
<span class="k">end</span>
</code></pre>
</div>

<p>否则如果用lua的原生语法的话，虽然也可以，但是会很臃肿，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"macosx"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"iphoneos"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"android"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"linux"</span><span class="p">)</span> <span class="k">then</span>
<span class="k">end</span>
</code></pre>
</div>

<p>除了<code class="highlighter-rouge">is_xxx</code>系列，像：<code class="highlighter-rouge">add_xxxs</code> 这种后缀有<code class="highlighter-rouge">s</code>的复数api，都是可以传递多个参数的哦，例如<code class="highlighter-rouge">add_files</code>：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"test.c"</span><span class="p">,</span> <span class="s2">"hello.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>等等，这里就不一一介绍了。。。</p>

<h3 id="is_arch"><code class="highlighter-rouge">is_arch</code></h3>

<p>这个跟<code class="highlighter-rouge">is_plat</code>类似，不过是用来判断当前编译的目标架构的，也就是：</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code>xmake f --arch<span class="o">=</span>x86_64
</code></pre>
</div>

<p>然后，我们在工程描述中，进行判断：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 如果当前架构是x86_64或者i386</span>
<span class="k">if</span> <span class="n">is_arch</span><span class="p">(</span><span class="s2">"x86_64"</span><span class="p">,</span> <span class="s2">"i386"</span><span class="p">)</span> <span class="k">then</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/xxx/*.c"</span><span class="p">)</span>
<span class="k">end</span>

<span class="c1">--如果当前平台是armv7, arm64, armv7s, armv7-a</span>
<span class="k">if</span> <span class="n">is_arch</span><span class="p">(</span><span class="s2">"armv7"</span><span class="p">,</span> <span class="s2">"arm64"</span><span class="p">,</span> <span class="s2">"armv7s"</span><span class="p">,</span> <span class="s2">"armv7-a"</span><span class="p">)</span> <span class="k">then</span>
    <span class="c1">-- ...</span>
<span class="k">end</span>
</code></pre>
</div>

<p>如果像上面那样一个个去判断所有arm架构，也许会很繁琐，毕竟每个平台的架构类型很多，xmake提供了类似<code class="highlighter-rouge">add_files</code>中的通配符匹配模式，来更加简洁的进行判断：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">--如果当前平台是arm平台</span>
<span class="k">if</span> <span class="n">is_arch</span><span class="p">(</span><span class="s2">"arm*"</span><span class="p">)</span> <span class="k">then</span>
    <span class="c1">-- ...</span>
<span class="k">end</span>
</code></pre>
</div>

<p>用*就可以匹配所有了。。</p>

<h3 id="is_os"><code class="highlighter-rouge">is_os</code></h3>

<p>这个很简单，用来判断当前编译目标，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 如果当前操作系统是ios</span>
<span class="k">if</span> <span class="n">is_os</span><span class="p">(</span><span class="s2">"ios"</span><span class="p">)</span> <span class="k">then</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/xxx/*.m"</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</div>

<p>目前支持的操作系统有：windows、linux、android、macosx、ios</p>

<h3 id="is_kind"><code class="highlighter-rouge">is_kind</code></h3>

<p>用来判断当前是否编译的是动态库还是静态库</p>

<p>一般用于如下场景：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="c1">-- 通过配置设置目标的kind</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"$(kind)"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*c"</span><span class="p">)</span>
    
    <span class="c1">-- 如果当前编译的是静态库，那么添加指定文件</span>
    <span class="k">if</span> <span class="n">is_kind</span><span class="p">(</span><span class="s2">"static"</span><span class="p">)</span> <span class="k">then</span>
        <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/xxx.c"</span><span class="p">)</span>
    <span class="k">end</span>

</code></pre>
</div>

<p>编译配置的时候，可手动切换，编译类型：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>
<span class="c1">-- 编译静态库</span>
<span class="n">xmake</span> <span class="n">f</span> <span class="o">-</span><span class="n">k</span> <span class="n">static</span>
<span class="n">xmake</span>

<span class="c1">-- 编译动态库</span>
<span class="n">xmake</span> <span class="n">f</span> <span class="o">-</span><span class="n">k</span> <span class="n">shared</span>
<span class="n">xmake</span>
</code></pre>
</div>

<h3 id="is_option"><code class="highlighter-rouge">is_option</code></h3>

<p>如果某个自动检测选项、手动设置选项被启用，那么可以通过<code class="highlighter-rouge">is_option</code>接口来判断，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>
<span class="c1">-- 如果手动启用了xmake f --demo=y 选项</span>
<span class="k">if</span> <span class="n">is_option</span><span class="p">(</span><span class="s2">"demo"</span><span class="p">)</span> <span class="k">then</span>
   
    <span class="c1">-- 编译demo目录下的代码</span>
    <span class="n">add_subdirs</span><span class="p">(</span><span class="s2">"src/demo"</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</div>

        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2016/07/22/how-to-compile-on-cross-toolchains/">如何通过xmake进行交叉编译</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2016/07/24/enable-pdb-on-windows/">xmake默认启用pdb符号文件</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
